package com.dao;

import com.pojo.Department;
import com.pojo.Employee;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@Repository
public class EmployeeDao {
   /* private static Map<Integer, Employee> employeeMap=null;
    private static DepartmentDao departmentDao=new DepartmentDao();
    private Integer employeeId=5;
    *//*模拟员工数据库*//*
    static {
        employeeMap =new HashMap<Integer, Employee>();
        employeeMap.put(1,new Employee(1,"小明","A@qq.com",1,departmentDao.findById(101)));
        employeeMap.put(2,new Employee(2,"小红","B@qq.com",0,departmentDao.findById(102)));
        employeeMap.put(3,new Employee(3,"小兆","C@qq.com",1,departmentDao.findById(103)));
        employeeMap.put(4,new Employee(4,"小刘","D@qq.com",0,departmentDao.findById(104)));
        employeeMap.put(5,new Employee(5,"小美","E@qq.com",0,departmentDao.findById(105)));
    }
    *//*模拟数据库CRUD操作*//*
    //查询所有的员工
    public Collection<Employee> findAll(){
        return employeeMap.values();
    }
    //通过ID查询员工
    public Employee findById(Integer id){
        return employeeMap.get(id);
    }
    //添加一个员工
    public void saveOne(Employee employee){
        if (employee.getId()==null){
            employee.setId(++employeeId);
        }
        employee.setLastName(employee.getLastName());
        employee.setGender(employee.getGender());
        employee.setEmall(employee.getEmall());
        employee.setDepartment(departmentDao.findById(employee.getDepartment().getId()));
        employee.setBirth(employee.getBirth());
        employeeMap.put(employee.getId(),employee);
    }
    public void delOne(Integer employeeId){
        employeeMap.remove(employeeId);
    }*/
}
